<?php
class Helper_ShowMod_Tpl  extends C_Helper
{
	public function Bulletin($mod_E)
	{
		$modify_url = $this->_view->getUrl("index","mod","bulletin",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id));	
		$RootOper  = Zend_Registry::get('RootOper');
		if($RootOper == 1) {$sort = 'sort';
		                    $modify = ' ( <a href="'.$modify_url.'">修改</a> )';
		}
		else {$sort = '';}
		
		
		
		return 
		'<div class="mod '.$sort.'" id="'.$mod_E->id.'">
			<div class="hd">
    		<h2>
	        	<span>'.$mod_E->title.'</span>
		        <span class="pl">
		               '.$modify.'
		        </span>
   			</h2>
		    <div class="edit">
		            <a href="#"  class="a_lnk_mod_setting">设置</a>
		        </div>
		    </div>

			<div class="bd">
				<pre class="bulletin-content">'.$mod_E->mapBulletin->getContent().'</pre>
			</div>
		</div>';
	}
	public function Message($mod_E)
	{
		$modify_url = $this->_view->getUrl("index","mod","message",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id));	
		$RootOper  = Zend_Registry::get('RootOper');
		if($RootOper == 1) {$sort = 'sort';
		                    $modify = ' ( <a href="'.$modify_url.'">修改</a> )';
		}
		else {$sort = '';}
		
		
		$message_list = $mod_E->mapMessagelist;	
		
		
		if(!empty($message_list))
		{
			foreach($message_list as $k => $message_E)
			{
				$message_html .= '
						<div class="update-item">
						    <div class="pic">
							    <a href="http://t.sina.com.cn/'.$message_E->mapUser->getUid().'">
							    <img width="36" height="36" src="'.$message_E->mapUser->getImage().'">
							    </a>
						    </div>
						    <div class="content">
						      <div class="author">
						         <a target="_blank" href="'.$message_E->mapUser->getHref().'"><img src="'.$message_E->mapUser->getIcon().'" >@'.$message_E->mapUser->getName().'</a>: '.$message_E->message.' 
						         <span class="datetime">'.$message_E->getCtime("Y-m-d").'</span>
						      </div>
						    </div>
						</div>';
			}
		}
		
		 $showtpl .= '<div class="mod '.$sort.'" id="'.$mod_E->id.'">
				<div class="hd">                
					<h2>        
						<span>'.$mod_E->title.'</span>
						                                                                                        
						<span class="pl">                                        
						</span>    
					</h2>    
					<div class="edit">            
						<a href="#" class="a_lnk_mod_setting">设置</a>        
					</div>    
				</div>
				<div class="bd">
					<div class="board">
					
						<form class="j a_add_board" name="bpform" action="'.$modify_url.'" method="post">
							<textarea name="text" class="board-text"></textarea>
							<span class="bn-flat"><input name="bp_submit" type="submit" value=" 留言 "></span>
						</form>
					'.$message_html.'
					</div>
				</div>
			</div>';
		$showtpl .= "
					<script type=\"text/javascript\">
					Do(function(){
						$(function(){
							$('#".$mod_E->id." form').submit(function(e){
								var err = $(this).find('.attn'), blank = '请填写内容';
								if ($.trim(this.elements['text'].value) === '') {
									if ( err.length > 0 ) {
										err.html(blank);
									} else {
										$(this).append(' &nbsp; <span class=\"attn\">' + blank + '</span>');
									}
									return false;
								}
							});
						});
					});
					</script>";
		
		
		
		return $showtpl;
	}
	public function Photo($mod_E)
	{
		$modify_url = $this->_view->getUrl("index","mod","photo",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id));
		$RootOper  = Zend_Registry::get('RootOper');
		
		$all_url = $this->_view->getUrl("index","mod","allphoto",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id));
		if($RootOper == 1) {$sort = 'sort';
		                    $modify = ' ( <a href="'.$modify_url.'">添加</a> )';
		}
		else {$sort = '';}
		
		
		$photo_list = $mod_E->mapPhotolist;	
		
		
		if(!empty($photo_list))
		{
			foreach($photo_list as $k => $photo_E)
			{
				
				$photo_url = $this->_view->getUrl("index","mod","detailphoto",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id,"photoid"=>$photo_E->id));
				$photo_html .= '
						<li>
			    			<a  href="'.$photo_url.'">
			    				<img src="'.$photo_E->getPhoto('100X100').'">
			    			</a>
			    		</li>';
			}
		}
		
		return '<div class="mod '.$sort.'" id="'.$mod_E->id.'">
    		<div class="hd">
    			<h2>
	       		 	<span>'.$mod_E->title.'</span>
	       			 <span class="pl">
	       			 <a href="'.$all_url.'">全部</a>
	       			 '.
	                 $modify
	       			 .'</span>
				</h2>


   				 <div class="edit">
           		 	<a href="#"  class="a_lnk_mod_setting">设置</a>
       			 </div>
   			</div>
			<div class="bd">
				<div class="widget-photo-list"> 
					<ul class="list-s"> 
			    	'.$photo_html.'	
					</ul> 
				</div> 
			</div>
		</div>';
		
	}
	public function Forum($mod_E)
	{
		$modify_url = $this->_view->getUrl("index","mod","forum",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id));
		$RootOper  = Zend_Registry::get('RootOper');
		
		if($RootOper == 1) {$sort = 'sort';}
		else {$sort = '';}
		$forum_list = $mod_E->mapForumlist;	
		if(!empty($forum_list))
		{
			foreach($forum_list as $k => $forum_E)
			{
				$forum_url = $this->_view->getUrl("index","mod","comment",array("siteid"=>$mod_E->siteid,"modid"=>$mod_E->id,"forumid"=>$forum_E->id));
				$forum_html .= '
				
				<tr>
			    <td>
			        <a href="'.$forum_url.'">'.$forum_E->title.'</a>
			    </td>
			    <td>来自
			    <a  target="_blank" href="'.$forum_E->mapUser->getHref().'"><img src="'.$forum_E->mapUser->getIcon().'" >@'.$forum_E->mapUser->getName().'</a>
			    </td>
			    <td nowrap="nowrap" class="count">
			       '.$forum_E->mapCommentCount.'
			    </td>
		    	<td class="date">'.$forum_E->getCtime("Y-m-d H:i").'</td>
				</tr>        
				';
			}
		}
		return 
		'<div class="mod '.$sort.'" id="'.$mod_E->id.'">
			<div class="hd">                
				<h2>        
					<span>'.$mod_E->title.'</span>                                                                                        
					<span class="pl">                                        
					( <a href="'.$modify_url.'">发言</a> )        
					</span>    
				</h2>    
				<div class="edit">            
				<a href="#" class="a_lnk_mod_setting">设置</a>        
				</div>    
			</div>
			<div class="bd">
				<table class="list-b">    
					<tr>
					<td>话题</td><td>作者</td>
					<td nowrap="nowrap">回应</td>
					<td align="right">更新时间</td>
					</tr>
	 				'.$forum_html.'
				</table>
			</div>
		</div>';
	}
}
?>